﻿<!-- Views/Shared/_Layout.cshtml -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - 在线考试系统</title>
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
    <style>
        .child-right {
            position: absolute;
            right: 0; /* 靠右 */
            top: 0; /* 根据需要调整 */
        }

        /* 现代化导航栏设计 */
        .navbar {
            box-shadow: 0 2px 15px rgba(0,0,0,.1);
            border: none;
            background-color: #ffffff !important;
            padding: 0 20px;
            border-bottom: 1px solid #eaeaea;
            min-height: 56px;
        }

        .navbar-brand {
            font-weight: 700;
            font-size: 1.6rem;
            letter-spacing: 0.5px;
            color: #2c3e50 !important;
        }

        .navbar-brand:hover {
            color: #3498db !important;
        }

        /* 导航链接样式 */
        .nav-link {
            font-weight: 600;
            font-size: 1.05rem;
            transition: all 0.3s ease;
            padding: 15px 18px;
            margin: 0 2px;
            border-radius: 6px;
            letter-spacing: 0.3px;
            color: #34495e !important;
            display: flex;
            align-items: center;
        }

        .nav-link:hover {
            color: #3498db !important;
            background-color: #f8f9fa;
            transform: translateY(-1px);
        }

        .nav-link.active {
            background-color: #e3f2fd;
            color: #1976d2 !important;
            box-shadow: 0 2px 4px rgba(0,0,0,.05);
        }

        /* 下拉菜单样式 */
        .dropdown-menu {
            border: 1px solid #eaeaea;
            box-shadow: 0 6px 12px rgba(0,0,0,.1);
            border-radius: 8px;
            margin-top: 8px;
            padding: 8px 0;
            background-color: #fff;
        }

        .dropdown-item {
            padding: 12px 20px;
            transition: all 0.2s ease;
            font-weight: 500;
            font-size: 1rem;
            color: #34495e !important;
            display: flex;
            align-items: center;
        }

        .dropdown-item:hover {
            background-color: #f8f9fa;
            color: #3498db !important;
            transform: translateX(3px);
        }

        .dropdown-divider {
            margin: 6px 0;
            border-top: 1px solid #e9ecef;
        }

        /* 用户信息区域 */
        .user-info {
            display: flex;
            align-items: center;
            color: #2c3e50 !important;
            padding: 12px 18px;
            margin: 0 5px;
            border-radius: 6px;
            font-weight: 600;
            font-size: 1.05rem;
            background-color: #f8f9fa;
            letter-spacing: 0.3px;
        }

        .user-info:hover {
            background-color: #e9ecef;
            color: #3498db !important;
        }

        .user-info .glyphicon-user {
            font-size: 1.1rem;
            color: #3498db;
        }

        /* 导航项间距 */
        .navbar-nav .nav-item {
            margin: 0 2px;
        }

        /* 响应式汉堡菜单 */
        .navbar-toggler {
            border: 1px solid #ddd;
            padding: 8px 12px;
            border-radius: 4px;
            background-color: #f8f9fa;
        }

        .navbar-toggler:hover {
            background-color: #e9ecef;
        }

        .navbar-toggler:focus {
            outline: none;
            box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
        }

     /*   .navbar-toggler-icon {
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(52, 73, 94, 0.9)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
        }*/

        /* 内容区域样式 */
        .body-content {
            padding: 20px 20px;
            margin-top: 25px;
            min-height: calc(100vh - 150px);
        }

        /* 页脚样式 */
        footer {
            background-color: #f8f9fa;
            padding: 25px 0;
            border-top: 1px solid #e9ecef;
            margin-top: 30px;
            box-shadow: 0 -2px 10px rgba(0,0,0,.03);
        }

        footer p {
            margin: 0;
            color: #6c757d;
            font-size: 0.95rem;
        }

        /* 移动端导航样式 */
        @@media (max-width: 991px) {
            .navbar {
                padding: 0 15px;
            }

            .navbar-collapse {
                position: absolute;
                top: 100%;
                left: 0;
                right: 0;
                background-color: #ffffff;
                box-shadow: 0 8px 16px rgba(0,0,0,.1);
                z-index: 1000;
                padding: 26px 0;
                border-top: 1px solid #eaeaea;
            }

            .navbar-nav {
                flex-direction: column;
                padding: 0;
            }

            .navbar-nav .nav-item {
                margin: 2px 0;
                width: 100%;
            }

            .nav-link {
                padding: 12px 20px;
                border-radius: 0;
                margin: 0;
                justify-content: flex-start;
            }

            .dropdown-menu {
                position: static;
                float: none;
                width: 100%;
                margin-top: 0;
                background-color: #f8f9fa;
                border: 0;
                box-shadow: none;
                padding: 0;
                border-radius: 0;
            }

            .dropdown-item {
                padding: 12px 40px;
                color: #34495e !important;
                border-radius: 0;
            }

            .user-info {
                padding: 12px 20px;
                border-radius: 0;
                margin: 0;
            }

            /* 移动端布局调整 - 防止重叠 */
            .navbar-nav.mr-auto {
                margin-right: 0 !important;
            }

            .navbar-nav.ml-auto {
                margin-left: 0 !important;
            }

            /* 移动端用户操作区域 */
            .user-actions {
                width: 30%;
                border-top: 1px solid #eaeaea;
                margin-top: 10px;
                padding-top: 0px;
            }

            .user-actions .nav-item {
                width: 100%;
            }

            .user-actions .nav-link {
                justify-content: flex-start;
            }
        }

        @@media (max-width: 767px) {
            .navbar-brand {
                font-size: 1.4rem;
            }

            .nav-link {
                padding: 10px 14px;
                font-size: 0.95rem;
            }

            .user-info {
                padding: 8px 12px;
                font-size: 0.95rem;
            }

            .body-content {
                padding: 15px 10px;
                margin-top: 10px;
            }
        }

        /* 图标样式优化 */
        .glyphicon {
            top: 1px;
            margin-right: 6px;
            font-size: 1.1em;
        }

        /* 修复按钮内图标和文字对齐 */
        .btn .glyphicon {
            top: 2px;
            margin-right: 5px;
            float: none;
        }

        .nav-link .glyphicon {
            margin-right: 8px;
            color: #7f8c8d;
        }

        .nav-link:hover .glyphicon {
            color: #3498db;
        }

        /* 活动状态图标 */
        .nav-link.active .glyphicon {
            color: #1976d2;
        }

        /* 修复按钮文字居中 */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .btn .glyphicon {
            margin-right: 5px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-light bg-white fixed-top">
        <div class="container-fluid">
            <a class="navbar-brand" href="@Url.Action("Index", Session["Role"].ToString() == "Admin" ? "Admin" : "Employee")">
                <span class="glyphicon glyphicon-blackboard"></span> 在线考试系统
            </a>
            <button class="navbar-toggler" type="button" id="navbarToggle" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="navbar-collapse collapse" id="navbarNav">
                @if (Session["UserId"] != null)
                {
                    if (Session["Role"].ToString() == "Admin")
                    {
                        <!-- 管理员导航菜单 -->
                        <ul class="navbar-nav mr-auto" id="mainNav">
                            <li class="nav-item">
                                <a class="nav-link" href="@Url.Action("Index", "Admin")">
                                    <span class="glyphicon glyphicon-home"></span> @WebApplication1.Utilities.LanguageManager.GetText("HomePage")
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="@Url.Action("Exams", "Admin")">
                                    <span class="glyphicon glyphicon-list-alt"></span> @WebApplication1.Utilities.LanguageManager.GetText("ExamManagement")
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="@Url.Action("ExamResults", "Admin")">
                                    <span class="glyphicon glyphicon-stats"></span>  @WebApplication1.Utilities.LanguageManager.GetText("ViewResults")
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="@Url.Action("Users", "Admin")">
                                    <span class="glyphicon glyphicon-user"></span> @WebApplication1.Utilities.LanguageManager.GetText("UserManagement")
                                </a>
                            </li>
                           
                        </ul>
                    }
                    else if (Session["Role"].ToString() == "Employee")
                    {
                        <!-- 员工导航菜单 -->
            <ul class="navbar-nav mr-auto" id="mainNav">
                <li class="nav-item">
                    <a class="nav-link" href="@Url.Action("Index", "Employee")">
                        <span class="glyphicon glyphicon-home"></span> @WebApplication1.Utilities.LanguageManager.GetText("HomePage")
                    </a>
                </li>

                <li class="nav-item">
                    <a class="nav-link" href="@Url.Action("MyExamResults", "Employee")">
                        <span class="glyphicon glyphicon-time"></span> @WebApplication1.Utilities.LanguageManager.GetText("ExamRecords")
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="@Url.Action("PracticeHistory", "Employee")">
                        <span class="glyphicon glyphicon-time"></span>  @WebApplication1.Utilities.LanguageManager.GetText("PracticeRecords")
                    </a>
                </li>
            </ul>
                    }

                    <!-- 用户操作区域 -->
            <ul class="navbar-nav user-actions child-right">
                <li class="nav-item">
                    <span class="user-info">
                        <span class="glyphicon glyphicon-user"></span>
                        <span>@Session["Username"]</span>
                    </span>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="@Url.Action("ChangePassword", "Account")">
                        <span class="glyphicon glyphicon-lock"></span>
                        <span>修改密码</span>
                    </a>
                </li>
                @*<li>
                    <div style="display: flex; align-items: center; height: 50px; padding: 0 15px;">
                        @{
                            string currentLang = WebApplication1.Utilities.LanguageManager.GetCurrentLanguage();
                        }
                        <a href="@Url.Action("ChangeLanguage", "Base", new { lang = "zh-CN", returnUrl = Request.RawUrl })"
                           class="btn btn-xs @(currentLang == "zh-CN" ? "btn-primary" : "btn-default")"
                           style="margin-right: 5px; border-radius: 15px; padding: 2px 8px; font-size: 11px;">
                            中文
                        </a>
                        <a href="@Url.Action("ChangeLanguage", "Base", new { lang = "vi-VN", returnUrl = Request.RawUrl })"
                           class="btn btn-xs @(currentLang == "vi-VN" ? "btn-primary" : "btn-default")"
                           style="border-radius: 15px; padding: 2px 8px; font-size: 11px;">
                            VN
                        </a>
                    </div>
                </li>*@
                <li class="nav-item">
                    <a class="nav-link" href="@Url.Action("Logout", "Account")">
                        <span class="glyphicon glyphicon-log-out"></span>
                        <span> @WebApplication1.Utilities.LanguageManager.GetText("Logout")</span>
                    </a>
                </li>
           
            </ul>
                }
            </div>
        </div>
    </nav>

    <div class="container-fluid body-content">
        @RenderBody()
    </div>

    <footer class="footer">
        <div class="container-fluid text-center">
            <p>&copy; @DateTime.Now.Year - 在线考试系统 | 版本 1.0</p>
        </div>
    </footer>

    <!-- 确保正确的脚本加载顺序 -->
    <script src="~/Scripts/jquery-3.6.0.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>

    <script>
        // 手动实现导航切换功能
        document.addEventListener('DOMContentLoaded', function () {
            var navbarToggle = document.getElementById('navbarToggle');
            var navbarNav = document.getElementById('navbarNav');

            if (navbarToggle && navbarNav) {
                navbarToggle.addEventListener('click', function (e) {
                    e.preventDefault();
                    navbarNav.classList.toggle('show');
                });

                // 点击导航项后关闭菜单（移动端）
                var navLinks = document.querySelectorAll('.nav-link');
                navLinks.forEach(function (link) {
                    link.addEventListener('click', function () {
                        if (window.innerWidth < 992) {
                            navbarNav.classList.remove('show');
                        }
                    });
                });

                // 点击外部区域关闭菜单
                document.addEventListener('click', function (e) {
                    if (!navbarNav.contains(e.target) && !navbarToggle.contains(e.target)) {
                        navbarNav.classList.remove('show');
                    }
                });
            }
        });
    </script>

    @RenderSection("scripts", required: false)
</body>
</html>